<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>注册</title>

    <meta name="description" content="Source code generated using layoutit.com">
    <meta name="author" content="LayoutIt!">

    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link href="../static/css/style.css" rel="stylesheet">

  </head>

<body style="padding: 20px;background: url('../static/images/loginbg.jpg')">
<div class="container-fluid">
	<div class="row">
		<div class="col-md-6">
		</div>
		<div class="col-md-4">
			<form method="post" id="signin_data" >
				<div class="form-group">

					<label for="exampleInputEmail1">
						Username
					</label>
					<input type="text" class="form-control" id="exampleInputEmail1" name="username" required placeholder="3~20位字母数字下划线"/>
				</div>
				<div class="form-group">

					<label for="exampleInputPassword1">
						Password
					</label>
					<input type="password" class="form-control" id="exampleInputPassword1" name="pwd" required placeholder="6~20位字母数字下划线"/>
				</div>

                <div class="form-group">

					<label for="exampleInputPassword1">
                        Verify Password
					</label>
					<input type="password" class="form-control" id="exampleInputPassword2" name="password" required/>
				</div>

                <div class="form-group">

					<label for="exampleInputPassword1">
						Email address
					</label>
					<input type="email" class="form-control" id="exampleInputPassword3" name="email" required/>
				</div>

				<input type="button" class="btn btn-primary" value="注册" id="sub" />


                <a href="/login" class="btn btn-primary">
					返回登录
				</a>
                <a href="/" class="btn btn-primary">
					返回首页
				</a>
			</form>
		</div>
		<div class="col-md-2">

		</div>
	</div>
</div>
<script src="../static/js/jquery.min.js"></script>
    <script  type="text/javascript" >

$("#sub").submit(function(e) {
    $.ajax({
        url:'/signin/run',
        type:'post',
        data:$("#signin_data").serialize(),
        success:function (status) {
            console.log(status)
            if(status.status==200){
                confirm("注册成功")
                window.location.href="/login"
            }
            else if(status.status==2){
                alert('写入数据库失败')

            }
            else if(status.status==3){
                alert('用户已存在')

            }
            else if(status.status==4){
                alert('两次密码不一致')

            }
            else if(status.status==5){
                alert('密码不合法')

            }
            else if(status.status==6){
                alert('用户名不合法')

            }
        },
        error:function (e) {
            console.log(e)
        }
    })
})
    </script>
</body>
</html>
